Basic use cases of redis in PHP and redisPHP. The basic use cases of redis in PHP, and the use cases of redisPHP download www. oschina. after netpredis is decompressed, it contains the lib source file, examples example, and test the basic use case
Php connection to redis database predis operations Daquan
Predis is the php database for connecting to redis. because it is fully written in php and uses a lot of namespace and closure functions, it only supports php5.3 and later versions,
Use AutoLoad to load related libraries, this point is to require $file; Spl_autoload_register (function ($class) {$file = __dir__. ' /lib/predis/'. $class.
PHP ';
if (file_exists ($file)) {require $file; return true;}});
Configure the connected IP,
Introduced
Redis is a key-value storage system. Like memcached, it supports a relatively larger number of stored value types, including string (string), list (linked list), set (set), Zset (sorted set– ordered set), and hash (hash type). These data
Use AutoLoad to load the relevant library, this is the key torequire$file; Spl_autoload_register (function ($class) {$file = __dir__. ' /lib/predis/'. $class. PHP '; if (file_exists ($file)) {require $file; return true;}); /Configure the connected
Predis is the PHP connection Redis Operation Library, because it completely uses PHP writing, a lot of use of namespaces and closures and other functions, only support php5.3 above, so the measured performance, 25,000 times per second read and write.
Download Http://www.oschina.net/p/redisAfter decompression, there are: Lib source files, examples examples, test testsCopy the Lib directory to your project and you can start your Predis operation.Use AutoLoad to load the relevant library, the focus
1. Problems with the mysql+memcached architecture
The actual MySQL is suitable carries on the massive data storage, through memcached hot spot data loading to the cache, speeds up the visit, many companies have used this kind of architecture, but
This article is mainly to share with you PHP operation Redis Life, hope to help everyone.
To confirm that the server has the Redis service turned onThe Redis port number is 6379 by default
A small example code
Header ("Content-type:text/html;charset=
This article mainly introduces the PHP + Redis basic operation, has a certain reference value, now share to everyone, the need for friends can refer to
String type operation
The string is the most basic type of Redis, and the string type is binary
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.